package com.hichat.provider.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.hichat.common.pojo.Friend;
import com.hichat.common.pojo.FriendExample;
import com.hichat.common.util.QueryData;
import com.hichat.common.util.ReturnResult;
import com.hichat.provider.service.FriendServiceImpl;

@RestController
@RequestMapping("/friend")
public class FriendController {

    @Autowired
    private FriendServiceImpl friendServiceImpl;


    @RequestMapping(value = "/saveFriend",method = RequestMethod.POST)
    public ReturnResult saveFriend(@RequestBody Friend friend){
        ReturnResult result = friendServiceImpl.insertFriend(friend);
        return result;
    }


    @RequestMapping(value="/getFriend/{userId}/{otherUserId}/{time}",method = RequestMethod.POST)
    public ReturnResult getFriend(@PathVariable Long userId, @PathVariable Long otherUserId,
                                   @PathVariable Date time,
                                   @RequestBody PageInfo pageInfo){
        ReturnResult result = friendServiceImpl.getFriend(userId, otherUserId, time,pageInfo);
        return result;
    }

    
    @RequestMapping("/getFriendList")
    public ReturnResult getFriendList(@RequestBody QueryData<FriendExample> queryData)throws Exception{
        ReturnResult result = friendServiceImpl.getFriendList(queryData);
        return result;
    }
}
